<template>
  <div class="app-container">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input size="small" v-model="queryItems[0].value" :placeholder="$t('companyName')" clearable/>
      </el-form-item>
      <el-form-item>
        <el-button size="mini" @click="getDataList()">{{ $t('query') }}</el-button>
      </el-form-item>
<!--      <el-form-item>-->
<!--        <el-button v-if="$hasPermission('sys:role:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>-->
<!--      </el-form-item>-->
<!--      <el-form-item>-->
<!--        <el-button v-if="$hasPermission('sys:role:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>-->
<!--      </el-form-item>-->
    </el-form>
    <el-table
      size="mini"
      v-loading="dataListLoading"
      :data="dataList"
      border
      stripe
      @sort-change="dataListSortChangeHandle"
      style="width: 100%;">
<!--      <el-table-column type="selection" header-align="center" align="center" width="50"/>-->
      <el-table-column prop="companyName" :label="$t('companyName')" header-align="center" />
<!--      <el-table-column prop="contractName" :label="$t('deal.contractName')" header-align="center" />-->
      <el-table-column prop="originalAmount" :label="$t('deal.originalAmount')" header-align="center" align="center" width="160">
        <template slot-scope="scope">
          <span>{{scope.row.originalAmount.toFixed(2)}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="rechargeAmount" :label="$t('deal.rechargeAmount')" header-align="center" align="center" width="160">
        <template slot-scope="scope">
          <span>{{scope.row.rechargeAmount.toFixed(2)}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="totalAmount" :label="$t('deal.totalAmount')" header-align="center" align="center" width="160">
        <template slot-scope="scope">
          <span v-if="scope.row.operation === 2">{{(scope.row.originalAmount- scope.row.rechargeAmount).toFixed(2)}}</span>
          <span v-else >{{(scope.row.originalAmount+scope.row.rechargeAmount).toFixed(2)}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="paymentType" :label="$t('deal.paymentType')" header-align="center" align="center" width="120">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.paymentType === 1" size="mini" >{{ $t('deal.paymentType1') }}</el-tag>
          <el-tag v-else-if="scope.row.paymentType === 2" size="mini" type="success">{{ $t('deal.paymentType2') }}</el-tag>
          <el-tag v-else-if="scope.row.paymentType === 3" size="mini" type="info">{{ $t('deal.paymentType3') }}</el-tag>
          <el-tag v-else-if="scope.row.paymentType === 4" size="mini" type="warning">{{ $t('deal.paymentType4') }}</el-tag>
          <el-tag v-else-if="scope.row.paymentType === 5" size="mini" type="warning">{{ $t('deal.paymentType5') }}</el-tag>
          <el-tag v-else-if="scope.row.paymentType === 6" size="mini" type="danger">{{ $t('deal.paymentType6') }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="operation" :label="$t('deal.operation')" header-align="center" align="center" width="120">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.operation === 2" size="mini" type="danger">{{ $t('deal.operation2') }}</el-tag>
          <el-tag v-else size="mini" type="success">{{ $t('deal.operation1') }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="remark" :label="$t('remark')" header-align="center" align="center"/>
<!--      <el-table-column prop="extraAmount" :label="$t('deal.extraAmount')" header-align="center" align="center"/>-->
      <el-table-column prop="createTime" :label="$t('role.createTime')" sortable="custom" header-align="center" align="center" width="180"/>
<!--      <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">-->
<!--        <template slot-scope="scope">-->
<!--          <el-button v-if="$hasPermission('sys:role:update')" type="text" size="mini" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>-->
<!--          <el-button v-if="$hasPermission('sys:role:delete')" type="text" size="mini" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->
    </el-table>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"/>
    <!-- 分页 -->
    <el-pagination
      slot="footer"
      :current-page="page"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="limit"
      :total="total"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="pageSizeChangeHandle"
      @current-change="pageCurrentChangeHandle">
    </el-pagination>
  </div>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './deal-add-or-update'
export default {
  name: "dealRecord",
  mixins: [ mixinViewModule ],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/manager/dealRecord/list',
        getDataListIsPage: true,
        deleteURL: '/manager/dealRecord/delete',
        deleteIsBatch: true
      },
      dataForm: {

      },
      queryItems: [
        {
          field: 'companyName',
          as: 'LIKE',
          value: ''
        }
      ],
      order: 'ASC',
      orderField: 'createTime'
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
